import {
  ajax,
  src,
  util
} from "../../utils/util.js";
Page({
 
  data: {
    agelist: ["一岁", "两岁", "三岁", "四岁", "五岁", "六岁", "七岁", "八岁", "九岁", "十岁", "十一岁", "十二岁", "十三岁", "十四岁", "十五岁"],
    autoplay: false,
    current:1,
    id:"",
    uqid:"",
    dogmsg:""
  },
  whenchange:function(e){
    // console.log(e.detail.current)
    var current = e.detail.current+1
    this.setData({
      current: current
    })
  },
  onLoad:function(options){
    var id=options.id
    var uqid = wx.getStorageSync("uqid");
    this.setData({
      id: id,
      uqid:uqid
    })
    this.getdotallmsg()
  },
  onShow:function(){
    this.getdotallmsg()
  },

  toupdatadog:function(e){
    var id = e.currentTarget.dataset.id;
    console.log(id )
    wx.navigateTo({
      url: '/pages/updatadog/updatadog?id='+id,
    })
  },

  getdotallmsg:function(){
    ajax("/api/user/my_pet_show", {
      data: {
        uqid: this.data.uqid,
        id: this.data.id
      },
      header: {
        'Accept': 'application/json', // 默认值
      },
      method: 'get'
    }, res => {
      console.log(res);
      if (res.error == 0) {//获取进展 pid
        this.setData({
          dogmsg:res.data
        })
      }
    })
  },

  delmypet:function(){
    ajax("/api/user/pet_del", {
      data: {
        uqid: this.data.uqid,
        id: this.data.id
      },
      header: {
        'Accept': 'application/json', // 默认值
      },
      method: 'DELETE'
    }, res => {
      console.log(res);
      if (res.error == 0) {//获取进展 pid
        wx.showToast({
          title: "删除成功",
          icon: 'none',
          duration: 3000,
          success: this.toback
        })
      }
    })
  },

  toback: function () {
    wx.navigateBack({
      delta: 1
    })
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }


})